package com.example.springboot_zc.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.springboot_zc.mapper.classDisMapper;
import com.example.springboot_zc.pojo.Class;
import com.example.springboot_zc.pojo.classDis;
import com.example.springboot_zc.service.classDisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Set;

@Transactional(rollbackFor=Exception.class)
@Service
public class classDisServiceImpl extends ServiceImpl<classDisMapper, classDis> implements classDisService {

    @Autowired
    classDisMapper classDisMapper;

    @Override
    public Set<String> getAllClass(){
        return classDisMapper.selectClassNum();
    }

    @Override
    public Integer getStatusNum(String class_num,String status){
        return classDisMapper.getStatusNum(class_num,status);
    }

    @Override
    public Integer getSN(String status){
        return classDisMapper.getSN(status);
    }

    @Override
    public boolean updateSta(String status,String stuNum){
        return classDisMapper.updateSta(status,stuNum);
    }

    @Override
    public void deleteByStu(String stuNum){
        classDisMapper.deleteByStu(stuNum);
    }

    @Override
    public Integer getStatu(String status) {
        LambdaQueryWrapper<classDis> lqw = new LambdaQueryWrapper<classDis>();
        lqw.eq(classDis::getStatus, status);
        List<classDis> cc = classDisMapper.selectList(lqw);
        return cc.size();
    }
}
